package com.qilu.pe.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alipay.sdk.app.PayTask;
import com.makeramen.roundedimageview.RoundedImageView;
import com.qilu.pe.R;
import com.qilu.pe.base.Base2Activity;
import com.qilu.pe.base.BaseResult2;
import com.qilu.pe.base.Config;
import com.qilu.pe.base.Global;
import com.qilu.pe.base.PayResult;
import com.qilu.pe.dao.bean.OrderDetail;
import com.qilu.pe.dao.bean.UPayInfo;
import com.qilu.pe.dao.bean.WxPayInfo;
import com.qilu.pe.dao.http.APIRetrofit;
import com.qilu.pe.support.util.AlertUtil;
import com.qilu.pe.support.util.GlideUtil;
import com.qilu.pe.support.util.Logg;
import com.ruitu.arad.Arad;
import com.ruitu.arad.api.RxUtil;
import com.ruitu.arad.base.base_list.ListBaseAdapter;
import com.ruitu.arad.base.base_list.SuperViewHolder;
import com.ruitu.arad.util.ToastUtils;
import com.tencent.mm.opensdk.modelpay.PayReq;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.unionpay.UPPayAssistEx;

import java.util.List;
import java.util.Map;

import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

// 订单详情
public class OrderDetailActivity extends Base2Activity {
    private TextView tv_in_pay;
    private TextView tv_name, tv_age, tv_sex, tv_phone, tv_time;// 患者信息
    private TextView tv_test_price, tv_discount, tv_freight, tv_coupon, tv_item_total;// 支付信息
    private TextView tv_price;
    private TextView tv_sample_time;
    private TextView et_clinic_diag, et_remark;
    private RecyclerView rcv_item, rcv_set, rcv_sample_consemu;// 项目列表,套餐列表,样本耗材列表
    private TextView tv_cancel, tv_ok;

    private ItemListAdapter itemAdapter;// 项目列表adapter
    private ComboListAdapter comboAdapter;// 套餐列表adapter
    private SampleAndConsumeListAdapter sampleAdapter;// 耗材adapter

    private String title = "订单详情";
    private String orderId;
    private String orderType;// 订单类型 订单状态 1 待付款,2 申请退款,3 订单取消,4 已退款,5 未接单,6 运输中,7 检验中,8 已出报告

    private OrderDetail detail;
    private String orderNum;// 订单号

    IWXAPI msgApi;

    @Override
    protected int getLayoutRes() {
        return R.layout.activity_order_detail;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        tv_in_pay = findViewById(R.id.tv_in_pay);
        tv_name = findViewById(R.id.tv_name);
        tv_age = findViewById(R.id.tv_age);
        tv_sex = findViewById(R.id.tv_sex);
        tv_phone = findViewById(R.id.tv_phone);
        tv_time = findViewById(R.id.tv_time);
        tv_test_price = findViewById(R.id.tv_test_price);
        tv_discount = findViewById(R.id.tv_discount);
        tv_freight = findViewById(R.id.tv_freight);
        tv_coupon = findViewById(R.id.tv_coupon);
        tv_item_total = findViewById(R.id.tv_item_total);
        tv_price = findViewById(R.id.tv_price);
        tv_sample_time = findViewById(R.id.tv_sample_time);
        et_clinic_diag = findViewById(R.id.et_clinic_diag);
        et_remark = findViewById(R.id.et_remark);
        rcv_item = findViewById(R.id.rcv_item);
        rcv_set = findViewById(R.id.rcv_set);
        rcv_sample_consemu = findViewById(R.id.rcv_sample_consemu);
        tv_cancel = findViewById(R.id.tv_cancel);
        tv_ok = findViewById(R.id.tv_ok);

        Bundle bundle = getIntent().getExtras();
        if (null != bundle) {
            title = bundle.getString("title");
            orderId = bundle.getString("orderId");
            orderType = bundle.getString("orderType");
        }
//        tv_cancel.setVisibility(View.GONE);// 默认不显示取消按钮
//        tv_ok.setVisibility(View.GONE);// 默认不显示支付按钮
        handleViewByOrderType();

        tv_in_pay.setText(title);
        setHeadTitle(title);

        hideProgress();
        reqOrderDetail();
        showProgress();

        itemAdapter = new ItemListAdapter(this);
        LinearLayoutManager manager = new LinearLayoutManager(this);
        rcv_item.setLayoutManager(manager);
        rcv_item.setAdapter(itemAdapter);

        comboAdapter = new ComboListAdapter(this);
        LinearLayoutManager manager2 = new LinearLayoutManager(this);
        rcv_set.setLayoutManager(manager2);
        rcv_set.setAdapter(comboAdapter);

        sampleAdapter = new SampleAndConsumeListAdapter(this);
        LinearLayoutManager manager3 = new LinearLayoutManager(this);
        rcv_sample_consemu.setLayoutManager(manager3);
        rcv_sample_consemu.setAdapter(sampleAdapter);

        setListeners();
        alert = new AlertDialog.Builder(this, R.style.Dialog_FS).create();

        msgApi = WXAPIFactory.createWXAPI(this, null);
        msgApi.registerApp(Config.WX_APP_ID);
    }

    // 根据订单类型 订单状态设置界面
    private void handleViewByOrderType() {
        // 订单状态 1 待付款,2 申请退款,3 订单取消,4 已退款,5 未接单,6 运输中,7 检验中,8 已出报告
        if (TextUtils.equals("1", orderType)) {// 待付款
            tv_cancel.setVisibility(View.VISIBLE);
            tv_ok.setVisibility(View.VISIBLE);
        } else if (TextUtils.equals("2", orderType)) {// 申请退款
            tv_cancel.setVisibility(View.GONE);
            tv_ok.setVisibility(View.GONE);
        } else if (TextUtils.equals("3", orderType)) {// 订单取消
            tv_cancel.setVisibility(View.GONE);
            tv_ok.setVisibility(View.GONE);
        } else if (TextUtils.equals("4", orderType)) {// 已退款
            tv_cancel.setVisibility(View.GONE);
            tv_ok.setVisibility(View.GONE);
        } else if (TextUtils.equals("5", orderType)) {// 未接单
            tv_cancel.setVisibility(View.VISIBLE);
            tv_ok.setVisibility(View.GONE);
        } else if (TextUtils.equals("6", orderType)) {// 运输中
            tv_cancel.setVisibility(View.GONE);
            tv_ok.setVisibility(View.GONE);
        } else if (TextUtils.equals("7", orderType)) {// 检验中
            tv_cancel.setVisibility(View.GONE);
            tv_ok.setVisibility(View.GONE);
        } else if (TextUtils.equals("8", orderType)) {// 已出报告
            tv_cancel.setVisibility(View.GONE);
            tv_ok.setVisibility(View.GONE);
        } else {
            tv_cancel.setVisibility(View.GONE);
            tv_ok.setVisibility(View.GONE);
        }
    }

    private void setListeners() {
        setOnClickListener(tv_cancel, tv_ok);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        if (v == tv_cancel) {// 取消订单
            AlertUtil.showComDialog(this, "是否取消该订单?", new AlertUtil.OnAlertBtnClickListner() {
                @Override
                public void onConfirmClick() {
                    hideProgress();
                    reqCancelOrder();
                    showProgress();
                }

                @Override
                public void onCancelClick() {

                }
            });
        }
        if (v == tv_ok) {// 去支付
            showDialog();
        }
    }

    private Disposable reqCancelOrder() {
        return APIRetrofit.getDefault().reqCancelOrder(Global.HEADER, orderId)
                .compose(RxUtil.<BaseResult2>subIoObMain())
                .subscribe(new Consumer<BaseResult2>() {
                    @Override
                    public void accept(BaseResult2 baseResult2) throws Exception {
                        hideProgress();
                        if (baseResult2.isSuccess()) {
                            finish();
                        } else {

                        }
                        ToastUtils.showShort(baseResult2.getMsg());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        hideProgress();
                        throwable.printStackTrace();
                        ToastUtils.showShort("取消订单失败");
                    }
                });
    }

    private AlertDialog alert;// 弹窗
    private View alert_view;
    String payType = "2";// 支付方式 1 微信,2 支付宝,3 银联支付,4 余额支付

    public void showDialog() {// 弹窗界面
        alert.show();
        alert_view = View.inflate(this, R.layout.layout_alert_choose_pay_type, null);

        final RadioButton cb_ali = alert_view.findViewById(R.id.cb_ali);
        final RadioButton cb_wx = alert_view.findViewById(R.id.cb_wx);
        final RadioButton cb_union = alert_view.findViewById(R.id.cb_union);
        final RadioButton cb_balance = alert_view.findViewById(R.id.cb_balance);
        final TextView tv_balance0 = alert_view.findViewById(R.id.tv_balance0);// 显示余额数量

        RelativeLayout rl_ali = alert_view.findViewById(R.id.rl_ali);
        RelativeLayout rl_wechat = alert_view.findViewById(R.id.rl_wechat);
        RelativeLayout rl_union_pay = alert_view.findViewById(R.id.rl_union_pay);
        RelativeLayout rl_balance = alert_view.findViewById(R.id.rl_balance);

        tv_balance0.setText("余额支付 (¥" + Global.ORG_BALANCE + ")");

        rl_ali.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                cb_ali.setChecked(true);
                cb_wx.setChecked(false);
                cb_union.setChecked(false);
                cb_balance.setChecked(false);
            }
        });
        cb_ali.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                cb_ali.setChecked(true);
                cb_wx.setChecked(false);
                cb_union.setChecked(false);
                cb_balance.setChecked(false);
            }
        });
        rl_wechat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                cb_ali.setChecked(false);
                cb_wx.setChecked(true);
                cb_union.setChecked(false);
                cb_balance.setChecked(false);
            }
        });
        cb_wx.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                cb_ali.setChecked(false);
                cb_wx.setChecked(true);
                cb_union.setChecked(false);
                cb_balance.setChecked(false);
            }
        });
        rl_union_pay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                cb_ali.setChecked(false);
                cb_wx.setChecked(false);
                cb_union.setChecked(true);
                cb_balance.setChecked(false);
            }
        });
        cb_union.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                cb_ali.setChecked(false);
                cb_wx.setChecked(false);
                cb_union.setChecked(true);
                cb_balance.setChecked(false);
            }
        });
        rl_balance.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                cb_ali.setChecked(false);
                cb_wx.setChecked(false);
                cb_union.setChecked(false);
                cb_balance.setChecked(true);
            }
        });
        cb_balance.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                cb_ali.setChecked(false);
                cb_wx.setChecked(false);
                cb_union.setChecked(false);
                cb_balance.setChecked(true);
            }
        });

        alert_view.findViewById(R.id.tv_ok).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (cb_ali.isChecked()) {
                    payType = "2";
                } else if (cb_wx.isChecked()) {
                    payType = "1";
                } else if (cb_union.isChecked()) {
                    payType = "3";
                } else if (cb_balance.isChecked()) {
                    payType = "4";
                }
                if (cb_ali.isChecked()) {// 支付宝
                    hideProgress();
                    reqAliPayInfo();
                    showProgress();
                } else if (cb_wx.isChecked()) {// 微信
                    hideProgress();
                    reqWxPayInfo();
                    showProgress();
                } else if (cb_union.isChecked()) {// 银联
                    hideProgress();
                    reqUPayPayInfo();
                    showProgress();
                } else if (cb_balance.isChecked()) {
                    hideProgress();
                    reqBalancePayInfo();
                    showProgress();
                }
                alert.dismiss();
            }
        });

        AlertUtil.setAlertBottomInStyle(alert.getWindow(), alert_view, this);
    }

    private Disposable reqBalancePayInfo() {
        if (TextUtils.isEmpty(orderNum)) {
            ToastUtils.showShort("订单号异常");
            return null;
        }
        return APIRetrofit.getDefault().reqPlaceOrderPayBalance(Global.HEADER, orderNum, payType)
                .compose(RxUtil.<BaseResult2>subIoObMain())
                .subscribe(new Consumer<BaseResult2>() {
                    @Override
                    public void accept(BaseResult2 baseResult2) throws Exception {
                        hideProgress();
                        if (baseResult2.isSuccess()) {
                            startActivity(PaySuccessActivity.class);
                        } else {
                            ToastUtils.showShort(baseResult2.getMsg());
                        }
                        Logg.i("pay_data_balance = " + baseResult2.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        hideProgress();
                        throwable.printStackTrace();
                    }
                });
    }

    private Disposable reqUPayPayInfo() {
        if (TextUtils.isEmpty(orderNum)) {
            ToastUtils.showShort("订单号异常");
            return null;
        }
        return APIRetrofit.getDefault().reqPlaceOrderPayUpay(Global.HEADER, orderNum, payType)
                .compose(RxUtil.<BaseResult2<UPayInfo>>subIoObMain())
                .subscribe(new Consumer<BaseResult2<UPayInfo>>() {
                    @Override
                    public void accept(BaseResult2<UPayInfo> baseResult2) throws Exception {
                        hideProgress();
                        if (baseResult2.isSuccess()) {
                            uPay(baseResult2.getData().getTn());
                        } else {
                            ToastUtils.showShort(baseResult2.getMsg());
                        }
                        Logg.i("pay_data_upay = " + baseResult2.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        hideProgress();
                        throwable.printStackTrace();
                    }
                });
    }

    private Disposable reqWxPayInfo() {
        if (TextUtils.isEmpty(orderNum)) {
            ToastUtils.showShort("订单号异常");
            return null;
        }
        return APIRetrofit.getDefault().reqPlaceOrderPayWx(Global.HEADER, orderNum, payType)
                .compose(RxUtil.<BaseResult2<WxPayInfo>>subIoObMain())
                .subscribe(new Consumer<BaseResult2<WxPayInfo>>() {
                    @Override
                    public void accept(BaseResult2<WxPayInfo> baseResult2) throws Exception {
                        hideProgress();
                        if (baseResult2.isSuccess()) {
                            wxPay(baseResult2);
                        } else {
                            ToastUtils.showShort(baseResult2.getMsg());
                        }
                        Logg.i("pay_data_wx = " + baseResult2.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        hideProgress();
                        throwable.printStackTrace();
                        ToastUtils.showShort("获取微信支付信息错误");
                    }
                });
    }

    private Disposable reqAliPayInfo() {
        if (TextUtils.isEmpty(orderNum)) {
            ToastUtils.showShort("订单号异常");
            return null;
        }
        return APIRetrofit.getDefault().reqPlaceOrderPayAli(Global.HEADER, orderNum, payType)
                .compose(RxUtil.<BaseResult2>subIoObMain())
                .subscribe(new Consumer<BaseResult2>() {
                    @Override
                    public void accept(BaseResult2 baseResult2) throws Exception {
                        hideProgress();
                        if (baseResult2.isSuccess()) {
                            String orderInfo = (String) baseResult2.getData();
                            aliPay(orderInfo);
                        } else {
                            ToastUtils.showShort(baseResult2.getMsg());
                        }
                        Logg.i("pay_data_ali = " + baseResult2.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        hideProgress();
                        throwable.printStackTrace();
                    }
                });
    }

    // 调起银联支付
    private void uPay(String tn) {
        // “00” – 银联正式环境
        // “01” – 银联测试环境，该环境中不发生真实交易
        String serverMode = "01";
        UPPayAssistEx.startPay(Arad.app, null, null, tn, serverMode);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data == null) {
            return;
        }
        String str = data.getExtras().getString("pay_result");
        if (str.equalsIgnoreCase("success")) {
            //显示支付结果
            ToastUtils.showShort("银联支付成功");
            // 结果为成功时，建议去商户后台查询一下再展示成功
        } else if (str.equalsIgnoreCase("fail")) {
            ToastUtils.showShort("银联支付失败");
        } else if (str.equalsIgnoreCase("cancel")) {
            ToastUtils.showShort("您取消了银联支付");
        }
    }

    // 调起微信支付
    private void wxPay(BaseResult2<WxPayInfo> baseResult2) {
        WxPayInfo wxPayInfo = baseResult2.getData();
        PayReq request = new PayReq();
        request.appId = wxPayInfo.getAppid();
        request.partnerId = wxPayInfo.getPartnerid();
        request.prepayId = wxPayInfo.getPrepayid();
        request.packageValue = "Sign=WXPay";
        request.nonceStr = wxPayInfo.getNoncestr();
        request.timeStamp = wxPayInfo.getTimestamp();
        request.sign = wxPayInfo.getSign();
        msgApi.sendReq(request);
    }

    // 调起支付宝支付
    private void aliPay(final String orderInfo) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                PayTask alipay = new PayTask(OrderDetailActivity.this);
                Map<String, String> result = alipay.payV2(orderInfo, true);

                Message msg = new Message();
                msg.what = 20100851;
                msg.obj = result;
                mHandler.sendMessage(msg);
            }
        }).start();
    }

    @SuppressWarnings("all")
    private Handler mHandler = new Handler() {
        public void handleMessage(Message msg) {
            //返回码，标识支付状态，含义如下：9000——订单支付成功 8000——正在处理中 4000——订单支付失败 5000——重复请求 6001——用户中途取消 6002——网络连接出错
            if (msg.what == 20100851) {
                PayResult payResult = new PayResult((Map<String, String>) msg.obj);
                String payStatus = payResult.getResultStatus();
                if (TextUtils.equals(payStatus, "9000")) {// 判断resultStatus 为9000则代表支付成功
                    // 该笔订单是否真实支付成功，需要依赖服务端的异步通知。
                    ToastUtils.showShort("支付成功");
                    paySuc();

                } else if (TextUtils.equals(payStatus, "6001")) {
                    ToastUtils.showShort("取消支付");
                } else {
                    // 该笔订单真实的支付结果，需要依赖服务端的异步通知。
                    ToastUtils.showShort("支付失败");
                }
            }
        }
    };

    private void paySuc() {
        startActivity(PaySuccessActivity.class);
    }

    private Disposable reqOrderDetail() {
        return APIRetrofit.getDefault().reqOrderDetail(Global.HEADER, orderId)
                .compose(RxUtil.<BaseResult2<OrderDetail>>subIoObMain())
                .subscribe(new Consumer<BaseResult2<OrderDetail>>() {
                    @Override
                    public void accept(BaseResult2<OrderDetail> result2) throws Exception {
                        hideProgress();
                        if (result2.isSuccess()) {
                            detail = result2.getData();
                            if (null != detail) {
                                setData2View();
                            }
                        } else {

                        }
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        hideProgress();
                        throwable.printStackTrace();
                    }
                });
    }

    // 设置页面数据
    private void setData2View() {

        OrderDetail.UserInfo user = detail.getUserInfo();
        if (null != user) {
            tv_name.setText(user.getName());
            tv_age.setText(user.getBirth());
            tv_sex.setText(TextUtils.equals("0", user.getSex()) ? "男" : "女");
            tv_phone.setText(user.getPhone());
        }

        OrderDetail.Order order = detail.getOrder();
        if (null != order) {
            orderNum = order.getOrder_num();// 保存订单号,支付的时候用到

            tv_time.setText(order.getTime());// 预约时间
            tv_test_price.setText("￥" + order.getPrice());
            tv_discount.setText("￥" + order.getDiscount());
            tv_freight.setText("￥" + order.getFreight());
//            tv_coupon.setText("￥" + order.get());// 10.24 优惠券无数据
            tv_item_total.setText("￥" + order.getMoney());
            tv_price.setText("总价：¥" + order.getMoney());

            tv_sample_time.setText(order.getSamp_time());
            et_clinic_diag.setText(order.getDiagnose());
            et_remark.setText(order.getRemark());
        }

        List<OrderDetail.Project> projectList = detail.getProject();
        itemAdapter.setDataList(projectList);

        List<OrderDetail.Combo> comboList = detail.getCombo();
        if (!isDataEmpty(comboList)) {
            List<OrderDetail.Combo.Info> infoList = comboList.get(0).getInfo();
            comboAdapter.setDataList(infoList);
        }

        List<OrderDetail.SubData> sampleList = detail.getSubData();
        sampleAdapter.setDataList(sampleList);
    }

    // 项目adapter
    private class ItemListAdapter extends ListBaseAdapter<OrderDetail.Project> {

        public ItemListAdapter(Context context) {
            super(context);
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_confirm_order_item_list;
        }

        @Override
        public void onBindItemHolder(SuperViewHolder holder, int position) {
            TextView tv_name = holder.getView(R.id.tv_name);
            TextView tv_time = holder.getView(R.id.tv_time);
            TextView tv_price = holder.getView(R.id.tv_price);

            OrderDetail.Project item = mDataList.get(position);

            tv_name.setText(item.getName());
            tv_time.setText(item.getDay() + "天");
            tv_price.setText("¥" + item.getPrice());
        }
    }

    // 套餐adapter
    private class ComboListAdapter extends ListBaseAdapter<OrderDetail.Combo.Info> {

        public ComboListAdapter(Context context) {
            super(context);
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_confirm_order_item_list;
        }

        @Override
        public void onBindItemHolder(SuperViewHolder holder, int position) {
            TextView tv_name = holder.getView(R.id.tv_name);
            TextView tv_time = holder.getView(R.id.tv_time);
            TextView tv_price = holder.getView(R.id.tv_price);

            OrderDetail.Combo.Info item = mDataList.get(position);

            tv_name.setText(item.getName());
            tv_time.setText(item.getDay() + "天");
            tv_price.setText("¥" + item.getPrice());
        }
    }

    // 耗材adapter
    private class SampleAndConsumeListAdapter extends ListBaseAdapter<OrderDetail.SubData> {

        public SampleAndConsumeListAdapter(Context context) {
            super(context);
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_sample_and_consume_list;
        }

        @Override
        public void onBindItemHolder(SuperViewHolder holder, int position) {
            TextView tv_consume = holder.getView(R.id.tv_consume);
            TextView tv_num = holder.getView(R.id.tv_num);
            TextView tv_name1 = holder.getView(R.id.tv_name1);
            TextView tv_name2 = holder.getView(R.id.tv_name2);
            TextView tv_name3 = holder.getView(R.id.tv_name3);
            TextView tv_hint = holder.getView(R.id.tv_hint);
            TextView tv_hint_info = holder.getView(R.id.tv_hint_info);
            RoundedImageView iv_sample_img = holder.getView(R.id.iv_sample_img);

            OrderDetail.SubData consume = mDataList.get(position);

            tv_consume.setText(consume.getName());
            tv_num.setText("×" + consume.getCount());
            tv_name1.setText(consume.getName());// consume.getSample()
            tv_name2.setText(TextUtils.equals("1", consume.getType()) ? "常温" : "冷藏");
            tv_name3.setText(consume.getCapacity());
            tv_hint.setText(consume.getSampling());
            tv_hint_info.setText(consume.getNotice());
            GlideUtil.loadImg(Config.URL_IMG + consume.getPicture(), iv_sample_img);
        }
    }
}